package com.chushouya.manager.dto.admin.finance;

import com.chushouya.manager.constants.SettleBizInAndOutEnum;
import com.chushouya.manager.constants.SettleBizTypeSimpleEnum;
import com.general.framework.core.lang.Lists;
import com.general.framework.core.schema.PageRequest;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.validation.constraints.NotNull;
import java.util.Date;
import java.util.List;
import java.util.Objects;

@Data
@ApiModel("资金账户查询API")
public class FinanceAccountRecordApiQuery extends PageRequest {

    @ApiModelProperty("资金账户ID")
    @NotNull(message = "资金账户ID不能为空")
    private Long accountId;

    @ApiModelProperty("交易时间")
    private Date tradeTimeStart;

    @ApiModelProperty("交易时间")
    private Date tradeTimeEnd;

    @ApiModelProperty("关键词")
    private String keyword;

    @ApiModelProperty("收入or支出")
    private Integer inOrOut;

    @ApiModelProperty(value = "交易类型", hidden = true)
    private List<Integer> bizTypes;

    @ApiModelProperty("交易类型:SettleBizTypeSimpleEnum")
    private Integer bizTypeSimple;

    public List<Integer> getBizTypes() {
        List<Integer> bizTypesList = Lists.newArrayList();
        if (Objects.nonNull(this.inOrOut)) {
            bizTypesList.addAll(SettleBizInAndOutEnum.get(inOrOut).getBizTypes());
        }
        if (Objects.nonNull(this.bizTypeSimple)) {
            bizTypesList.addAll(SettleBizTypeSimpleEnum.get(bizTypeSimple).getBizTypes());
        }
        return bizTypesList;
    }
}
